//
//  SetUpDomainViewController.m
//  NoNameAmazing
//
//  Created by Hero on 17/9/1.
//  Copyright © 2017年 北京执行力科技有限公司. All rights reserved.
//

#import "SetUpDomainViewController.h"

@interface SetUpDomainViewController ()
@property (nonatomic ,strong)UITextField *tf;
@end

@implementation SetUpDomainViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self prepareUI];
    self.view.backgroundColor = UIColorFromRGB(0xEFEFF5);
    
}

- (void)prepareUI{
    UIView *bgView = [[UIView alloc]init];
    bgView.backgroundColor = UIColorFromRGB(0xffffff);
    [self.view addSubview:bgView];
    [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view).offset(10);
        make.left.right.equalTo(self.view);
        make.right.equalTo(self.view);
        make.height.equalTo(@45);
        
    }];
    UILabel *lable = [[UILabel alloc]init];
    lable.text = @"域名设置";
    lable.font = [UIFont systemFontOfSize:16];
    lable.textColor = UIColorFromRGB(0x333333);
    [bgView addSubview:lable];
    [lable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(bgView).offset(10);
        make.center.equalTo(bgView);
        
    }];
    _tf = [[UITextField alloc]init];
    if([us valueForKey:kBaseUrL]!=nil&&![[us valueForKey:kBaseUrL]isEqualToString:@""]){
        _tf.text = [us valueForKey:kBaseUrL];
    }else{
    _tf.placeholder = @"输入域名";
    }
    [bgView addSubview:_tf];
    [_tf mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(bgView).offset(80);
        make.center.equalTo(bgView);
        make.right.equalTo(bgView);
    }];
    
    UIButton *button = [[UIButton alloc]init];
    [button setTitle:@"完成" forState:UIControlStateNormal];
    [button addTarget:self action:@selector(commitBtnClick) forControlEvents:UIControlEventTouchUpInside];
    button.backgroundColor = UIColorFromRGB(0x1A7BE5);
    button.layer.cornerRadius = 4;
    button.layer.masksToBounds = YES;
    [self.view addSubview:button];
    [button mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(bgView.mas_bottom).offset(84);
        make.left.equalTo(self.view).offset(15);
        make.right.equalTo(self.view).offset(-15);
        make.height.equalTo(@44);
    }];
}
- (void)commitBtnClick{
    if (_tf.text.length == 0) {
        [self.view showHUDWithTitle:@"请输入域名"];
        return;
    }
    
    [us setValue:_tf.text forKey:kBaseUrL];
    [self.navigationController popViewControllerAnimated:YES];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end
